Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use POSIXErrorCode instead of direct errno E constants from wasi-libc #811

Conversation

kateinoigakukun
Copy link
Member

wasi-libc's E constants cannot be imported directly by ClangImporter, so we should use POSIXErrorCode from Swift instead.

@kateinoigakukun
Copy link
Member Author

@swift-ci test

@kateinoigakukun kateinoigakukun force-pushed the pr-2cef32c5c48a62ff1ed41cd448248092fd3c0bf6 branch from bea8dbb to 9532cea Compare August 2, 2024 04:09
@kateinoigakukun
Copy link
Member Author

@swift-ci test

wasi-libc's E constants cannot be imported directly by ClangImporter,
so we should use `POSIXErrorCode` from Swift instead.
@kateinoigakukun kateinoigakukun force-pushed the pr-2cef32c5c48a62ff1ed41cd448248092fd3c0bf6 branch from 9532cea to c25ca66 Compare August 2, 2024 04:34
@kateinoigakukun
Copy link
Member Author

@swift-ci test

@kateinoigakukun kateinoigakukun changed the title Use POSIXErrorCode instead of direct errno E constants from libc Use POSIXErrorCode instead of direct errno E constants from wasi-libc Aug 2, 2024
#if os(WASI)
// wasi-libc's errno.h constants cannot be directly imported into Swift
// so we use Swift stdlib's POSIXErrorCode instead
_EOPNOTSUPP = POSIXErrorCode.EOPNOTSUPP.rawValue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workaround here was put in place because the POSIXErrorCode.EOPNOTSUPP does not exist on platforms like Darwin (likely an oversight / a missing enum case). Does that case actually exist on WASI? If so, we might as well avoid this check entirely and just always evaluate the true branch of the if statement rather than worrying about storing this variable on a per-platform basis.

Also, is this something that can/should be fixed in the WASI overlay? There are a few other places where we use these error code constants that I expect would hit the same issue

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, is this something that can/should be fixed in the WASI overlay? There are a few other places where we use these error code constants that I expect would hit the same issue

Good pointing! This reminds me that we already provide errno constant shims in the overlay, and I just realized it missed some of them including EOPNOTSUPP.

So this change should be unnecessary after swiftlang/swift#75671

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants